package com.mqy;

import com.mqy.entity.Page;
import com.mqy.entity.UserLocation;
import com.mqy.service.HbaseSaltUserLocationDaoImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.util.concurrent.ListenableFutureCallback;

import java.util.List;

@SpringBootApplication
public class PhoenixHbaseApplication implements ApplicationListener<ContextRefreshedEvent> {

	public static void main(String[] args) {
		SpringApplication.run(PhoenixHbaseApplication.class, args);
	}

	@Autowired
	private HbaseSaltUserLocationDaoImpl hbaseSaltUserLocationDao;

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		UserLocation userLocation = new UserLocation();
		userLocation.setUserId(111L);
		Long count = hbaseSaltUserLocationDao.count(userLocation);
		System.out.println("===============" + count + "===============");
		List<UserLocation> query = hbaseSaltUserLocationDao.query(userLocation, Boolean.FALSE);
		query.forEach(v -> System.out.println(v.toString()));
		Page<UserLocation> page = new Page<>();
		hbaseSaltUserLocationDao.query(userLocation, page);
		hbaseSaltUserLocationDao.add(userLocation);
		Long count1 = hbaseSaltUserLocationDao.count(userLocation);
		System.out.println("===============" + count1 + "===============");
		List<UserLocation> query1 = hbaseSaltUserLocationDao.query(userLocation, Boolean.FALSE);
		query1.forEach(v -> System.out.println(v.toString()));
	}
}
